home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 1
/
Gekikoh Dennoh Club Vol. 1 (Japan).7z
/
Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin
/
tools
/
ebsx130
/
jisconv2.c
< prev
next >
Wrap
Text File
|
1997-05-07
|
11KB
|
462 lines
/* kenji suzuki */
/* JIS to shift-JIS converter for 広辞苑 */
#include "common2.h"
#include <iocslib.h>
/* #include <stdio.h> */
#include <method\Dos_i.h>
int steps; /* kenji suzuki */
unsigned short gra_x; /* kenji suzuki */
unsigned short gra_y; /* kenji suzuki */
static unsigned int get_int( void )
{
unsigned int c;
DOSREAD( cdfile , &c , sizeof( unsigned int ) );
steps+=4;
return( c );
};
static unsigned short get_short( void )
{
unsigned short c;
DOSREAD( cdfile , &c , sizeof( unsigned short ) );
steps+=2;
return( c );
};
static unsigned char get_char( void )
{
unsigned char c;
DOSREAD( cdfile , &c , sizeof( unsigned char ) );
steps++;
return( c );
};
static int jis2ank(int c)
{
int ch,cc;
ch=c&0xff;
cc=0xffff0000+'?';
if ((c&0x2300)==0x2300) {
cc=ch;
} else if ((c&0x2100)==0x2100) {
switch (ch) {
case 0x21: cc=' '; break;
case 0x27: cc=':'; break;
case 0x28: cc=';'; break;
case 0x29: cc='?'; break;
case 0x2a: cc='!'; break;
case 0x3c:
case 0x3d:
case 0x3e: cc='-'; break;
case 0x3f: cc='/'; break;
case 0x5c: cc='+'; break;
case 0x5d: cc='-'; break;
case 0x70: cc='$'; break;
case 0x73: cc='%'; break;
case 0x74: cc='#'; break;
case 0x75: cc='&'; break;
case 0x76: cc='*'; break;
case 0x77: cc='@'; break;
case 0x7e: cc=' '; break;
}
}
return cc;
}
/* original char* jis2shift(jischar *str , char *op, size_l length, int type) */
int jis2shift(char *op, size_l length, int type , int *nextflg )
{
int code; /* kenji suzuki */
jischar c,ch;
int k;
char *p=op;
char zenkaku=1;
jischar s1,s2,s3,s4; /* kenji suzuki */
int count; /* kenji suzuki */
unsigned char flg;
unsigned char cb;
unsigned char ccode;
int cnt;
int endflg;
unsigned short arw = '◎';
/* 97/5/1 epwing */
int indexnum;
unsigned char num , num2;
unsigned int wk;
*nextflg = 1;
steps = 0;
endflg = 0;
/*
c = get_short( );
DOSSEEK( cdfile , -2 , SEEK_CUR );
*/
for (;;) {
/* kenji suzuki */
if( e_key == 0 )
{
c = get_short( );
cb = (unsigned char)( c >> 8 );
flg = ( c & 0x00ff );
} else {
cb = get_char( );
};
/* original c=*str++; */
if (cb==0x1f) {
if( e_key == 1 )
{
flg = get_char( );
};
switch (flg) {
case 0x02: break;
case 0x03:
*nextflg = 0;
*p++=0;
return steps;
case 0x04:
zenkaku=0; break;
case 0x05:
zenkaku=1; break;
/* kenji suzuki */ case 0x06:
break;
/* kenji suzuki */ case 0x07:
break;
case 0x09:
/* kenji suzuki */
c = get_short( );
/* original c=*str++;
if(c!=1&&c!=5)printf("(1f09:%x)",c); */
if (c==1) {
if( endflg == 0 )
{
endflg = 9; /* 最初にみつかった物は無視 */
} else if( endflg == 9 )
{
*p++=0;
return steps-4; /* 2番目でリターン */
};
}
break;
case 0x0a:
/* original if (type!=0) { */
/* kenji suzuki */ if (type==0) {
*p++=0x0d, *p++=0x0a;
break;
}
*p++=0;
return steps;
/* kenji suzuki */ case 0x0e:
break;
/* kenji suzuki */ case 0x0f:
break;
/* kenji suzuki */ case 0x10:
break;
/* kenji suzuki */ case 0x11:
break;
case 0x41: /* ポイントの切りかえ? */
/* kenji suzuki */
if( endflg == 0 )
{
c = get_short( );
endflg = 41; /* 最初にみつかった物は無視 */
} else if( endflg == 41 )
{
*p++=0;
return steps-2; /* 2番目でリターン */
} else {
c = get_short( );
};
/* original *str++; */
break;
case 0x61: /* ポイントを元に戻す? */
/* *p++ = (char)((arw & 0xff00) >> 8);
*p++ = (char)arw & 0x00ff;
*/ /* *p++='(',*p++='6',*p++='1',*p++=')';
*/ break;
case 0x42:
*p++ = (char)((arw & 0xff00) >> 8);
*p++ = (char)arw & 0x00ff;
push_link_a( 3 , p-op-2 );
break;
case 0x62:
/* kenji suzuki 参照 */
indexpage = get_int( );
c = get_short( );
indexoff = (unsigned int)c;
indexpage = conv_hex( indexpage );
indexoff = conv_hex( indexoff );
push_link_b( ((indexpage-1)*0x800)+indexoff );
/* kenji suzuki printf("(%x:%x,%x,%x)",c,s1,s2,s3); */
/* original printf("(%x:%x,%x,%x)",c,*str,*(str+1),*(str+2));
str+=3;
*p++='(',*p++='6',*p++='2',*p++=')';
*/
break;
case 0x43:
*p++ = (char)((arw & 0xff00) >> 8);
*p++ = (char)arw & 0x00ff;
push_link_a( 2 , p-op-2 );
break;
case 0x63:
/* kenji suzuki メニュー */
indexpage = get_int( );
c = get_short( );
indexoff = (int)c;
indexpage = conv_hex( indexpage );
indexoff = conv_hex( indexoff );
push_link_b( ((indexpage-1)*0x800)+indexoff );
break;
/* kenji suzuki */ case 0x45:
c = get_short( );
count = 0;
break;
/* kenji suzuki */ case 0x65:
break;
/* kenji suzuki */ case 0x31: /* サイズ */
c = get_short( );
gra_x = get_short( );
gra_y = get_short( );
break;
/* kenji suzuki */ case 0x51:
break;
/* kenji suzuki */ case 0x32:
*p++ = (char)((arw & 0xff00) >> 8);
*p++ = (char)arw & 0x00ff;
push_link_a( 1 , p-op-2 );
break;
/* kenji suzuki グラフィック? */ case 0x52:
indexpage = get_int( );
c = get_short( );
indexoff = (int)c;
indexpage = conv_hex( indexpage );
indexoff = conv_hex( indexoff );
push_link_b( ((indexpage-1)*0x800)+indexoff );
break;
/* kenji suzuki 音声? */ case 0x33: /* ファイル型? */
/* *p++ = (char)((arw & 0xff00) >> 8);
*p++ = (char)arw & 0x00ff;
*/ break;
/* kenji suzuki */ case 0x53:
DOSREAD( cdfile , &c , sizeof( unsigned short ) );
DOSREAD( cdfile , &s1 , sizeof( unsigned short ) );
DOSREAD( cdfile , &s2 , sizeof( unsigned short ) );
DOSREAD( cdfile , &s3 , sizeof( unsigned short ) );
steps+=8;
break;
/* kenji suzuki 音声? */ case 0x34: /* トラック型? */
/* *p++ = (char)((arw & 0xff00) >> 8);
*p++ = (char)arw & 0x00ff;
*/ break;
/* kenji suzuki */ case 0x54:
indexpage = get_short( );
DOSREAD( cdfile , &s1 , sizeof( unsigned short ) );
DOSREAD( cdfile , &s2 , sizeof( unsigned short ) );
DOSREAD( cdfile , &s3 , sizeof( unsigned short ) );
steps+=6;
break;
/* 97/5/1 epwing */
case 0x0b:
break;
case 0x0c:
break;
case 0x14:
DOSSEEK( cdfile , 4 , SEEK_CUR );
break;
case 0x15:
break;
/* サイズ */ case 0x44:
c = get_short( );
wk = get_int( );
gra_y = conv_hex( wk );
wk = get_int( );
gra_x = conv_hex( wk );
*p++ = (char)((arw & 0xff00) >> 8);
*p++ = (char)arw & 0x00ff;
push_link_a( 4 , p-op-2 );
break;
/* グラフィック */ case 0x64:
indexpage = get_int( );
c = get_short( );
indexoff = (unsigned int)c;
indexpage = conv_hex( indexpage );
indexoff = conv_hex( indexoff );
push_link_b( ((indexpage-1)*0x800)+indexoff );
break;
case 0x47:
break;
/* */ case 0x67:
indexnum = 0;
num = get_char( );
while( num == 0x1e )
{
num2 = get_char( );
indexnum = (indexnum*10) + conv_hex( (int)num2 );
num = get_char( );
};
DOSSEEK( cdfile , -1 , SEEK_CUR );
steps--;
break;
case 0x4a:
DOSSEEK( cdfile , 16 , SEEK_CUR );
break;
case 0x6a:
break;
case 0x4d:
DOSSEEK( cdfile , 18 , SEEK_CUR );
break;
case 0x6d:
break;
/* 0d,12,13,4b,4c,6b,6cは */ case 0x0d:
/* 実際には見たことはない */ break;
/* けど一応入れておく */ case 0x12:
break;
case 0x13:
break;
case 0x4b:
break;
case 0x6b:
break;
case 0x4c:
break;
case 0x6c:
break;
default:
/* kenji suzuki */
DOSREAD( cdfile , &c , sizeof( unsigned short ) );
DOSREAD( cdfile , &s1 , sizeof( unsigned short ) );
DOSREAD( cdfile , &s2 , sizeof( unsigned short ) );
DOSREAD( cdfile , &s3 , sizeof( unsigned short ) );
DOSREAD( cdfile , &s4 , sizeof( unsigned short ) );
steps+=10;
/* printf("(%x:%x,%x,%x,%x)",c,s1,s2,s3,s4); */
/* original printf("[%x,%x,%x,%x,%x]",
c,*str,*(str+1),*(str+2),*(str+3)); */
*p++=0;
return steps;
}
} else {
/* orignal if (c==0xa169) ch=k=0x8391; */ /* 'ヱ' */
/* orignal else if (c==0xa168) ch=k=0x8390; */ /* 'ヰ' */
if( e_key == 0 )
{
/* kenji suzuki */ if( c >= f1jisst && c <= f1jised )
/* 全角外字の表示 */ {
ch = 0;
if( c <= f1jismax )
{
if( c >= f1jisst+0x100 )
code = c - ( f1jisst+0x100 ) + 94;
else
code = c - f1jisst;
*p++ = (char)( codetbl1[ code ] >> 8 );
*p++ = (char)( codetbl1[ code ] & 0x00ff );
} else {
*p++ = ' ';
*p++ = ' ';
};
}
/* kenji suzuki */ else if( c >= f2jisst && c <= f2jised )
/* 半角外字の表示 */ {
ch = 0;
if( c <= f2jismax )
{
if( c >= f2jisst+0x100 )
code = c - ( f2jisst+0x100 ) + 94;
else
code = c - f2jisst;
*p++ = (char)( codetbl2[ code ] >> 8 );
*p++ = (char)( codetbl2[ code ] & 0x00ff );
} else {
*p++ = ' ';
*p++ = ' ';
};
}
else if (0xb536<=c&&c<=0xb545) {
ch=0;
*p++='(';
if (c>0xb536+9-1) *p++='1';
*p++=((c-0xb536+1)%10)+'0';
*p++=')';
} else ch=k=JISSFT(c);
/* if (k<0) {
printf(":%4x.%4x:",*(str-2),c);
ch=('?'<<8)+'?';
}
*/
} else {
if( cb == f2esc ) /* 範囲はこれで良いのか */
/* 半角外字の表示 */ {
ch = 0;
ccode = get_char( );
if( ccode <= f2ascmax )
{
*p++ = (char)( codetblebg[ ccode ] >> 8 );
*p++ = (char)( codetblebg[ ccode ] & 0x00ff );
} else {
*p++ = ' ';
};
}
else if( cb >= 0x80 ) /* 0x80以上はどんな文字か判らないのでスペースを表示 */
{
ch = ' ';
} else {
ch = cb;
};
};
if (ch) {
if( e_key == 0 )
{
if (!(c==0x2121 ||(c&0xff00)==0x2300) || zenkaku) {
*p++=ch>>8;
*p++=ch;
} else {
*p++=jis2ank(c);
};
} else {
*p++=ch;
}
}
}
}
}
/*
#include <stdio.h>
wchar instr[50000];
char outstr[100000];
int main(int argc, char *argv[])
{
FILE *fp;
char *cp;
fp=fopen(argv[1],"r"); if (fp==NULL) return 1;
DOSREAD(instr,1,sizeof(instr),fp);
jis2shift(instr,outstr,sizeof(outstr));
cp=outstr;
while ( *cp ) putchar(*cp++);
}
*/